#include<stdio.h>
#include<stdbool.h>

#define size 100
int top = 0;
char a[100];

bool push(char x) {
    if (top > size - 1)return false;
    else {
        a[top] = x;
        top++;
        return true;
    }
}

char pop(void) {
    if (top == 0) return '\0';
    else {
        top--;
        return a[top];
    }
}

int check(char x, char y) {
    if (x == '\0' || x == '@') {
        printf("NO");
        return 0;
    }
    else if (x != y) {
        printf("NO");
        return 0;
    }
    else return 1;
}

int main() {
    char ch, out;
    int i = 1;
    push('@');
    ch = getchar();
    while (ch != '@') {
        switch (ch) {
            case '[':
            case '(':
            case '{':
                push(ch);
                break;
            case ']':
                out = pop();
                i = check(out, '[');
                break;
            case '}':
                out = pop();
                i = check(out, '{');
                break;
            case ')':
                out = pop();
                i = check(out, '(');
                break;
            default:
                break;
        }
        ch = getchar();
        if (i == 0) break;
    }
    out = pop();
    if (i == 1) {
        if (out == '@') {
            printf("YES");
        } else {
            printf("NO");
        }
    }
    return 0;
}
